package com.sfac.javaSpringBoot.modules.account.dao;

import com.sfac.javaSpringBoot.modules.account.entity.User;
import com.sfac.javaSpringBoot.modules.test.entity.City;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserDao {
    @Insert("insert into account_user(create_date,user_name,email,password)" +
            "values(#{createDate},#{userName},#{email},#{password})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void insertUser(User user);


    @Update("update account_user set user_name = " +
            "#{userName}, email = #{email},password = #{password} " +
            "where id = #{id}")
    void updateUser(User user);

    @Delete("delete from account_user where id = #{id}")
    void deleteUser(int id);


    //查询用户的账号和密码
    @Select("select * from account_user where user_name = #{userName}" +
            " and password = #{password}")
    User getUserByUserNameAndPassword(@Param("userName")String userName,
                                      @Param("password")String password);

}
